package com.zhuoyue.biz.core.api.dto.rep;

import com.zhuoyue.biz.core.api.domain.GatewayDO;
import com.zhuoyue.common.utils.Time;
import lombok.Data;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.BeanUtils;

import java.time.LocalDateTime;
import java.util.Collections;
import java.util.List;

/**
 * @author wjming
 * @ClassName: GatewayRepDTO
 * @Description:
 * @Date 2021-07-01 17:23
 */
@Data
public class GatewayRepDTO extends BaseRepDTO {
    /**
     * 所属家庭ID
     */

    private String homeId;

    /**
     * ZigBee模块mac地址
     */

    private String zigbeeMac;

    /**
     * WIFI模块mac地址
     */

    private String wifiMac;

    /**
     * WIFI模块IP地址
     */

    private String wifiIp;

    /**
     * 网关类型
     */
    private String gatewayType;

    /**
     * 网关名称
     */

    private String name;

    /**
     * 自动入网标志
     */

    private String zdrwbz;


    /**
     * 布防状态
     */

    private String defendStatus;

    /**
     * 报警状态
     */

    private String alarmStatus;

    /**
     * 图片地址
     */

    private String imgUrl;


    private String hardwareVersionNumber;


    private String softwareVersionNumber;


    private String manufacturerCode;

    private String gatewayPush;
    /**
     * 产品信息
     */
    private ProdInformation prodInformation;

    /**
     * 现在时间
     */

    private Long nowTime;

    /**
     * 设备状态时间
     */

    private Long switchTime;

    /**
     * 网关DO转华为回应数据的DTO
     *
     * @param gatewayDo
     * @return
     */
    public GatewayRepDTO gatewayDoToDto(GatewayDO gatewayDo, List<String> functionList) {
        if (gatewayDo == null) {
            return null;
        }
        setId(gatewayDo.getId());
        setCreateTime(gatewayDo.getCreateTime());
        BeanUtils.copyProperties(gatewayDo, this);
        this.nowTime = Time.toLongMilli(gatewayDo.getNowTime());
        this.switchTime = Time.toLongMilli(gatewayDo.getSwitchTime());
        this.prodInformation = new ProdInformation().getInformation(functionList);
        return this;
    }

}
